package com.intelligent.mts.da.handler;

import com.intelligent.mts.da.xmlmessage.HttpXmlRequest;
import com.intelligent.mts.da.xmlmessage.HttpXmlResponse;
import com.intelligent.mts.da.xmlmessage.Validate;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * Created by Garen.Pang on 2016/9/6.
 */
public class HttpXmlWSDLCilentHandler extends
        SimpleChannelInboundHandler<HttpXmlResponse> {

    @Override
    public void channelActive(ChannelHandlerContext ctx) {

        HttpXmlRequest request = new HttpXmlRequest(null, "WSDL");
        ctx.writeAndFlush(request);

    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
        cause.printStackTrace();
        ctx.close();
    }

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, HttpXmlResponse msg) throws Exception {
        System.out.println("The client receive response of http header is : "
                + msg.getHttpResponse().headers().names());
        System.out.println("The client receive response of http body is : "
                + msg.getResult());

    }
}